using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.ComponentModel;

namespace produccion.clases
{

    class CLSDETPRCP : ObservableObject
    {

MDOgeneral mod = new MDOgeneral();

#region Metodos basicos tabla

public int Insertar(string Ord, string Ref, string Col, string Tal, double Can, string Prc, int Consecutivo)
{
    try
    {
        string query = "insert into detprcp (nroord_dpp, codprc_dpp, consec_dpp, codref_dpp, codcol_dpp, codtal_dpp, canpro_dpp) values ('" + Ord + "','" + Prc + "'," + Consecutivo + ",'" + Ref + "','" + Col + "','" + Tal + "'," + Can + ")";
        return mod.comando(query);
    }
    catch (Exception ex) { throw ex; }
}

public int Consecutivo(string Ord, string Ref, string Col)
{
    try
    {
        string query = "select nvl(max(consec_dpp),0) from detprcp where nroord_dpp='" + Ord + "' and codref_dpp='" + Ref + "' and codcol_dpp='" + Col + "'";
        DataTable dt = new DataTable();
        dt = mod.consulta(query);
        if (dt.Rows.Count > 0)
        {
            
            int Con = System.Convert.ToInt16(dt.Rows[0][0].ToString());
            return Con + 1;
        }
        return 1;
    }
    catch (Exception ex) { throw ex; }
}

#endregion

#region  Propiedades
private string _NROORD_DPP;
public string NROORD_DPP
    {
        get { return _NROORD_DPP; }
        set
        {
            _NROORD_DPP = value;
            RaisePropertyChangedEvent("NROORD_DPP");
        }
    }
private string _CODPRC_DPP;
public string CODPRC_DPP
    {
        get { return _CODPRC_DPP; }
        set
        {
            if (_CODPRC_DPP != value) { CAMBIO = true; }
            _CODPRC_DPP = value;
            RaisePropertyChangedEvent("CODPRC_DPP");
        }
    }
private int _CONSEC_DPP;
public int CONSEC_DPP
{
    get { return _CONSEC_DPP; }
    set
    {
        if (_CONSEC_DPP != value) { CAMBIO = true; }
        _CONSEC_DPP = value;
        RaisePropertyChangedEvent("CONSEC_DPP");
    }
}
private int _CANPRO_DPP;
public int CANPRO_DPP
    {
        get { return _CANPRO_DPP; }
        set
        {
            if (_CANPRO_DPP != value) { CAMBIO = true; }
            _CANPRO_DPP = value;
            RaisePropertyChangedEvent("CANPRO_DPP");
        }
    }
private string _CODREF_DPP;
public string CODREF_DPP
{
    get { return _CODREF_DPP; }
    set
    {
        if (_CODREF_DPP != value) { CAMBIO = true; }
        _CODREF_DPP = value;
        RaisePropertyChangedEvent("CODREF_DPP");
    }
}
private string _CODCOL_DPP;
public string CODCOL_DPP
{
    get { return _CODCOL_DPP; }
    set
    {
        if (_CODCOL_DPP != value) { CAMBIO = true; }
        _CODCOL_DPP = value;
        RaisePropertyChangedEvent("CODCOL_DPP");
    }
}
private string _CODTAL_DPP;
public string CODTAL_DPP
{
    get { return _CODTAL_DPP; }
    set
    {
        if (_CODTAL_DPP != value) { CAMBIO = true; }
        _CODTAL_DPP = value;
        RaisePropertyChangedEvent("CODTAL_DPP");
    }
}
private Boolean _CAMBIO = false;
public Boolean CAMBIO
    {
        get { return _CAMBIO; }
        set
        {
            _CAMBIO = value;
            RaisePropertyChangedEvent("CAMBIO");
        }
    }
private Boolean _EXISTE = false;
 public Boolean EXISTE
    {
        get { return _EXISTE; }
        set
        {
            _EXISTE = value;
            RaisePropertyChangedEvent("EXISTE");
        }
    }


         
#endregion

    }
}
